package com.qdu.servlet;

import com.qdu.service.EmployeeService;
import com.qdu.service.impl.EmployeeServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 该Servlet负责处理修改员工头像的请求
 *
 * @author Anna
 */
@WebServlet("/meps")
public class ModifyEmployeePhotoServlet extends HttpServlet {
    
    EmployeeService employeeService = new EmployeeServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        //1. 获取请求参数
        req.setCharacterEncoding("utf-8");
        String eid = req.getParameter("empId");
        String ephoto = req.getParameter("empPhoto");
        
        //2. 调用业务逻辑，完成请求处理
        int rows=employeeService.modifyEmployeePhoto(eid, ephoto);
        
        //3. 生成响应内容，这里返回受影响的行数用于判断是否修改成功
        resp.getWriter().print(rows);
    }
}
